package tech.aistar.controller.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import tech.aistar.entity.*;
import tech.aistar.service.demand.impl.CategoryDetailServiceImpl;
import tech.aistar.service.demand.impl.CategoryServiceImpl;
import tech.aistar.service.services.impl.ServicesServiceImpl;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: lya
 * @Description: 本类的作用描述:
 * @CreateDate: 2019/10/3
 * @Version: 1.0
 */
@Controller
@RequestMapping("/services")
public class ServicesController {

    @Autowired
    private CategoryServiceImpl categoryService;

    @Autowired
    private CategoryDetailServiceImpl categoryDetailService;

    @Autowired
    private ServicesServiceImpl servicesService;


    @GetMapping("/serviceReleaseView")
    public String serviceReleaseView(Model model){
        List<Category> categoryList =  categoryService.findAll();
        model.addAttribute("categoryList",categoryList);

        return "services/serviceRelease";
    }

    @ResponseBody
    @RequestMapping("getCategoryDetail")
    public List<CategoryDetail> getCategoryDetail(Integer id){
        List<CategoryDetail> categoryDetailList = categoryDetailService.findAll(id);
        return categoryDetailList;
    }


    @PostMapping("/serviceRelease")
    @ResponseBody
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
//    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    public Result Release(@RequestBody Services services, HttpServletRequest req){
        req.getParameter("");



        System.out.println(services);
        servicesService.add(services);

        return new Result(CodeStatus.OK,true,"发布成功!",services);

    }

}